from typing import List

from langchain_ollama import ChatOllama

from common_config import CHAT_OLLAMA_MODEL


def validate_user(user_id: str, addressed: List[str]) -> bool:
    """Validate user using historical addresses.

    Args:
        user_id: (str) the user id
        addressed: Previous addresses.
    """
    # 这里可以实现具体的验证逻辑
    print(f"Validating user {user_id} with addresses: {addressed}")
    return False


llm = ChatOllama(
    model=CHAT_OLLAMA_MODEL,
    temperature=0,
)

llm_bind_tools = llm.bind_tools([validate_user])

# 构造输入，确保模型能够解析并调用工具函数
result = llm_bind_tools.invoke(
    "Could you validate user 123? They previously lived at "
    "123 Fake St in Boston MA and 234 Pretend Boulevard in "
    "Houston TX"
)

print(f"Result: {result}")

tool_calls = result.tool_calls
print(f"Tool calls: {tool_calls}")